package com.hornsun.apply.api;

import com.hornsun.apply.service.ApplyService;
import com.hornsun.util.IpSecurity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 该文件的作用：//TODO
 * </p>
 *
 * @author xuxin
 * @date 2018/9/11
 */

@RestController
@RequestMapping("/api/apply")
public class ApplyApi {

    @Autowired
    private ApplyService applyService;

    @PostMapping("/unifiedOrder")
    public ResponseEntity<?> unifiedOrder(HttpServletRequest httpRequest, String orderGuid) throws Exception {
        String ip = IpSecurity.getIPAddress(httpRequest);
        String openId = (String) httpRequest.getAttribute("openid");
        Map<String,String> map = applyService.unifiedOrder(orderGuid, ip, openId);
        return new ResponseEntity(HttpStatus.OK);
    }

}
